<template>
	<view class="container">
		<view class="status">
			<image v-if="orderInfo.status===1||orderInfo.status===2" src="../../../static/img/status1.png" mode=""></image>
			<image v-else-if="orderInfo.status===0" src="../../../static/img/status2.png" mode=""></image>
			<image v-else src="../../../static/img/status3.png" mode=""></image>
		</view>
		<view class="content">
			<view class="title">
				{{orderInfo.goods_name}}
			</view>
			<view class="jigou">
				<text>{{orderInfo.shop_name}}</text>
			</view>
			<view class="shijian">
				<image src="../../../static/icon/shijian2.png" mode=""></image>
				<text>{{orderInfo.spec}}</text>
			</view>
			<view class="local">
				<image src="../../../static/icon/dizhi-3@2x.png" mode=""></image>
				<text>{{orderInfo.shop_address}}</text>
			</view>
		</view>
		<view class="total">
			<text>总金额：</text>
			<text>{{orderInfo.total_price}}</text>
		</view>
		<view class="orderInfo">
			<view class="item">
				订单号：<text>{{orderInfo.order_no}}</text> 
			</view>
			<view class="item">
				创建时间：<text>{{orderInfo.createtime}}</text> 
			</view>
			<view class="item" v-if="orderInfo.pay_time!==0">
				付款时间：<text>{{orderInfo.pay_time}}</text> 
			</view>
			<view class="item">
				支付方式：<text>{{orderInfo.pay_type==='wechat'?"微信":"余额"}}</text> 
			</view>
			<view class="item">
				发票信息：<text>请联系老师，开具发票</text> 
			</view>
		</view>
		<view class="pay" v-if="orderInfo.status!==1&&orderInfo.status!==2">
			<view class="shifu">
				实付：<text>{{orderInfo.total_price}}</text>
			</view>
			<view class="payBtn" @click="pay()">
				立即支付
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				order_id:"",
				token:"",
				orderInfo:""
			}
		},
		onLoad: function(option) {
			uni.showLoading({
				title:"加载中...",
				mask:true
			})
			this.order_id = option.order_id;
			uni.showLoading({  
			    title: '加载中'  
			});
			uni.getStorage({
				key: 'user_info',
				success: (res) => {
					this.token = res.data.token;
					this.getData()
				},
				fail: (res) => {
					uni.redirectTo({
						url: '../../login/auth'
					});
				}
			});
		},
		methods:{
			pay(){
				uni.redirectTo({
					url: `../../order/index?order=${this.orderInfo.order_no}`
				});
			},
			getData(){
				uni.request({
					url: `https://mx.acktechnologies.com.cn/api/wxapp/mine/order/orderInfo`,
					data: {
						"token": this.token,
						"order_id":this.order_id
					},
					method: 'GET',
					success: res => {
						console.log(res)
						if (res.data.code === 1) {
							this.orderInfo = res.data.data;
							uni.hideLoading();
						} else if (res.data.code === 403) {
							uni.redirectTo({
								url: '../../login/auth'
							});
						} else {
							uni.showToast({
								title: '服务器开小差了呢，请您稍后再试',
								icon: 'none'
							})
						}
					},
					fail: () => { //接口请求失败的处理
						uni.showToast({
							title: '服务器开小差了呢，请您稍后再试',
							icon: 'none'
						})
					},
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		width: 100%;
		height: 100%;
		background: #F9F9FB;
	}
	.status{
		width: 750rpx;
		height: 160rpx;
		image{
			width: 750rpx;
			height: 160rpx;
		}
	}
	.content{
		background-color: #FFFFFF;
		padding: 40rpx;
		box-sizing: border-box;
		.title{
			font-size: 16px;
			font-weight: 500;
			color: #333333;
		}
		.jigou{
			margin-top: 15rpx;
			text {
				display: inline-block;
				padding: 4px 2px 3px 2px;
				background: #FFFFFF;
				border-radius: 2px;
				border: 1px solid #66A8A0;
				font-size: 12px;
				line-height: 12px;
				color: #66A8A0;
			}
		} 
		.shijian,.local{
			display: flex;
			flex-direction: row;
			align-items: center;
			font-size: 13px;
			color: #666666;
			margin-top: 15rpx;
			text{
				margin-left: 10rpx;
			}
		}
		.shijian image{
			width: 13px;
			height: 13px;
		}
		.local image{
			width: 12px;
			height: 15px;
		}
	}
	.total{
		padding: 40rpx;
		background-color: #FFFFFF;
		margin-top: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		text:nth-child(1){
			font-size: 16px;
			color: #666666;
		}
		text:nth-child(2){
			font-size: 18px;
			font-weight: 500;
			color: #333333;
		}
	}
	.orderInfo{
		padding: 0 0 50rpx 40rpx;
		background-color: #FFFFFF;
		overflow: hidden;
		margin-top: 20rpx;
		.item{
			margin-top: 35rpx;
			font-size: 15px;
			color: #666666;
			text{
				font-size: 13px;
			}
		}
	}
	.pay{
		width: 750rpx;
		height: 88rpx;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 0 40rpx;
		box-sizing: border-box;
		.shifu{
			font-size: 13px;
			color: #999999;
			text{
				font-size: 18px;
				font-weight: 500;
				color: #DD3A3A;
			}
		}
		.payBtn{
			width: 170rpx;
			height: 60rpx;
			line-height: 60rpx;
			background: #FD5629;
			border-radius: 30rpx;
			font-size: 15px;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
		}
	}
</style>
